//package com.hitqz.robot.biz.flow.component.agv;
//
//import cn.hutool.core.date.DateUtil;
//import com.alibaba.fastjson.JSONObject;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.hitqz.robot.api.business.model.dto.FlowContextDto;
//import com.hitqz.robot.api.business.model.dto.FlowPatrolPreAndEndTicketsDto;
//import com.hitqz.robot.api.common.entity.Robot;
//import com.hitqz.robot.api.common.entity.RobotMapPos;
//import com.hitqz.robot.api.common.entity.TicketsTask;
//import com.hitqz.robot.biz.service.RobotMapPosService;
//import com.hitqz.robot.biz.service.RobotService;
//import com.yomahub.liteflow.annotation.LiteflowComponent;
//import com.yomahub.liteflow.core.NodeComponent;
//import lombok.AllArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.http.HttpEntity;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.MediaType;
//import org.springframework.web.client.RestTemplate;
//
//import java.util.Date;
//
///**
// * @author xupkun
// * @date 2024/11/5
// */
//@Slf4j
//@LiteflowComponent(value = "NotifyServerArriveTargetPos", name = "[轮对/轮轴]到达终点前置点通知")
//@AllArgsConstructor
//public class NotifyServerArriveTargetPos extends NodeComponent {
//
//    private final RestTemplate restTemplate;
//
//    private final RobotService robotService;
//
//    private final RobotMapPosService robotMapPosService;
//
//    @Override
//    public void process() throws Exception {
//        Robot robot = robotService.getDefaultRobot();
//        FlowContextDto dto =  this.getRequestData();
//        TicketsTask task = dto.getTicketsTask();
//        FlowPatrolPreAndEndTicketsDto ticketsDto = JSONObject.parseObject(dto.getTicketsTask()
//                .getParseOrderParams(), FlowPatrolPreAndEndTicketsDto.class);
//        String sourceName = ticketsDto.getModalData().get("targetPosName")== null ?
//                String.valueOf(ticketsDto.getModalData().get("targetPosCode")):
//                String.valueOf(ticketsDto.getModalData().get("targetPosName"));
//        RobotMapPos prePos = robotMapPosService.getOne(Wrappers.<RobotMapPos>lambdaQuery()
//                .eq(RobotMapPos::getPreCode, sourceName)
//                .eq(RobotMapPos::getMapCode, robot.getMapCode()));
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.valueOf("application/json;UTF-8"));
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("sbID", robot.getRobotSn());
//        jsonObject.put("fktime", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
//        jsonObject.put("arrivePos", prePos.getName());
//        HttpEntity<String> strEntity = new HttpEntity<String>(jsonObject.toString(), headers);
//        try {
//            log.info("请求参数:" + strEntity.toString());
//            String result = restTemplate.postForObject("http://172.24.0.191:8090/api/v1/centreApp/agv/arrive/",
//                    strEntity, String.class);
//            log.info("reset session" + result);
//        }catch (Exception e) {
//            log.info("到达前置点通知:" + e.getMessage());
//        }
//
//    }
//}
